Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20240628.0 #21223

Merged
merged 12 commits into from
Jun 28, 2024
Merged

20240628.0 #21223

merged 12 commits into from
Jun 28, 2024

Conversation

piitaya
Copy link
Member

@piitaya piitaya commented Jun 28, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced dialog for adding application credentials with custom Home Assistant buttons.
    • Added "icon" field to multiple sections in the interface, improving customization options.
  • Bug Fixes

    • Corrected label text in Automation, Scene, and Script pickers from "state" to "icon" for clarity.
  • Dependency Updates

    • Updated various dependencies for improved stability and performance.
  • Refactor

    • Improved configuration handling in Lovelace cards for better efficiency.
    • Applied new CSS rules for better layout in horizontal stack cards.
  • Enhancements

    • Added new credential type "homeassistant" when adding users.

Copy link
Contributor

coderabbitai bot commented Jun 28, 2024

Walkthrough

Walkthrough

The update entails various dependency upgrades, user interface enhancements, and minor functionality adjustments within the Home Assistant project. Updates include version bumps for key dependencies, UI component replacements from Material Web Components to Home Assistant-specific components, and refined labels for consistency.

Changes

Files/Paths Change Summary
package.json, pyproject.toml Updated dependencies and project version respectively.
.../dialog-add-application-credential.ts Replaced Material Web Components buttons with Home Assistant buttons.
.../ha-automation-picker.ts, .../ha-scene-dashboard.ts, .../ha-script-picker.ts Changed label from "state" to "icon" for UI consistency.
.../dialog-add-user.ts Added "homeassistant" credential type to the user credentials upon user addition.
.../hui-card.ts Added _elementConfig property and refactored methods for better configuration handling in HuiCard.
.../hui-horizontal-stack-card.ts Introduced a CSS rule for hui-card elements to enhance their layout within HuiHorizontalStackCard.
src/translations/en.json Added new key-value pairs "icon": "Icon" to several sections for translation purposes.

Sequence Diagram(s)

None.


Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between d72e8c3 and b81314f.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (11)
  • package.json (3 hunks)
  • pyproject.toml (1 hunks)
  • src/panels/config/application_credentials/dialog-add-application-credential.ts (4 hunks)
  • src/panels/config/application_credentials/ha-config-application-credentials.ts (12 hunks)
  • src/panels/config/automation/ha-automation-picker.ts (1 hunks)
  • src/panels/config/scene/ha-scene-dashboard.ts (1 hunks)
  • src/panels/config/script/ha-script-picker.ts (1 hunks)
  • src/panels/config/users/dialog-add-user.ts (1 hunks)
  • src/panels/lovelace/cards/hui-card.ts (4 hunks)
  • src/panels/lovelace/cards/hui-horizontal-stack-card.ts (1 hunks)
  • src/translations/en.json (3 hunks)
Additional context used
Biome
src/panels/lovelace/cards/hui-horizontal-stack-card.ts

[error] 26-26: Using super in a static context can be confusing.

super refers to a parent class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

src/panels/lovelace/cards/hui-card.ts

[error] 103-103: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 114-114: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 163-163: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 171-171: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 172-172: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

src/panels/config/users/dialog-add-user.ts

[error] 272-272: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 285-285: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 298-298: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

src/panels/config/application_credentials/dialog-add-application-credential.ts

[error] 91-91: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 147-147: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 153-153: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 274-274: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 283-283: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 284-284: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 289-289: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 313-313: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 318-318: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

src/panels/config/application_credentials/ha-config-application-credentials.ts

[error] 259-259: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

src/panels/config/scene/ha-scene-dashboard.ts

[error] 215-215: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 233-233: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 233-233: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 843-843: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 854-854: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 867-867: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 890-890: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 830-830: Excessive complexity detected.

Please refactor this function to reduce its complexity score from 28 to the max allowed complexity 25.

(lint/complexity/noExcessiveCognitiveComplexity)


[error] 1042-1042: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1086-1086: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1089-1089: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1093-1093: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1094-1094: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

src/panels/config/script/ha-script-picker.ts

[error] 220-220: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 240-240: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 240-240: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 857-857: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 868-868: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 881-881: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 904-904: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 844-844: Excessive complexity detected.

Please refactor this function to reduce its complexity score from 28 to the max allowed complexity 25.

(lint/complexity/noExcessiveCognitiveComplexity)


[error] 957-957: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1067-1067: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1082-1082: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1086-1086: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1093-1093: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1120-1120: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1135-1135: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1153-1153: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1162-1162: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1163-1163: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1169-1169: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1177-1177: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

src/panels/config/automation/ha-automation-picker.ts

[error] 230-230: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 251-251: Forbidden non-null assertion.

(lint/style/noNonNullAssertion)


[error] 251-251: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 964-964: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 975-975: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 989-989: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1012-1012: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 951-951: Excessive complexity detected.

Please refactor this function to reduce its complexity score from 28 to the max allowed complexity 25.

(lint/complexity/noExcessiveCognitiveComplexity)


[error] 1137-1137: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1138-1138: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1147-1147: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1171-1171: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

Additional comments not posted (14)
pyproject.toml (1)

7-7: Version update approved.

The version has been incremented as per the PR objectives.

src/panels/lovelace/cards/hui-horizontal-stack-card.ts (1)

33-35: New CSS rule approved.

The addition of display: contents for hui-card elements should help with layout consistency without affecting stacking context.

src/panels/config/users/dialog-add-user.ts (1)

293-297: New credential addition approved.

Adding a credential of type "homeassistant" aligns with the functional enhancements mentioned in the PR summary. Ensure that proper validation and error handling are in place for security.

package.json (1)

158-158: Dependency updates approved.

The updates to dependencies such as @bundle-stats/plugin-webpack-filter, @typescript-eslint/eslint-plugin, and mocha are correctly reflected and align with the PR objectives.

Also applies to: 188-189, 223-223

src/panels/config/application_credentials/dialog-add-application-credential.ts (2)

13-13: Component Replacement: Import change approved.

The import change from @material/mwc-button to ../../../components/ha-button aligns with the component replacement strategy mentioned in the summary.


Line range hint 234-247: Check Button Slot and Logic Consistency.

The slot attribute for the cancel button has changed from primaryAction to secondaryAction. Ensure this aligns with the design requirements. Additionally, verify the conditional logic for disabling the primary action button, which seems appropriate given the conditions.

- <ha-button slot="primaryAction" @click=${this._abortDialog}>
+ <ha-button slot="secondaryAction" @click=${this._abortDialog}>
Verification successful

Check Button Slot and Logic Consistency.

The slot attribute for the cancel button has changed from primaryAction to secondaryAction. This aligns with the existing usage pattern for ha-button slots across the project, ensuring consistency with other dialogs and components.

  • Verified slot usage for primaryAction is consistent across the codebase.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the usage consistency of ha-button slots across the project.
rg --type typescript 'slot="primaryAction"' 'src/**/*.ts'

Length of output: 94



Script:

#!/bin/bash
# Verify the usage consistency of ha-button slots across the project.
rg --type ts 'slot="primaryAction"' 'src/**/*.ts'

Length of output: 103



Script:

#!/bin/bash
# Find all TypeScript files in the repository to determine the correct directory structure.
fd --extension ts

Length of output: 92109



Script:

#!/bin/bash
# Verify the usage consistency of ha-button slots across the project.
rg 'slot="primaryAction"' --glob '**/*.ts'

Length of output: 17705

src/panels/config/application_credentials/ha-config-application-credentials.ts (2)

50-77: Review Storage Decorator Usage.

The introduction of multiple @storage decorators for managing UI state like sorting, column order, hidden columns, and search filters is a good practice for maintaining user preferences across sessions. Ensure that the keys and options are correctly configured and do not conflict with other parts of the application.


165-171: Verify Event Handling Logic.

The handling of sorting, column changes, and search events is crucial for the dynamic behavior of the data table. Ensure that these handlers are robust and perform well under various user interactions.

src/panels/config/scene/ha-scene-dashboard.ts (1)

246-246: Label Modification: Correct Implementation.

The change from "state" to "icon" in the label for scene configurations aligns with the summary's mention of making labels more reflective of their functionality.

src/panels/config/script/ha-script-picker.ts (1)

255-255: Updated label to better reflect functionality.

The change from "state" to "icon" in the label property of the icon column is consistent with the PR objectives and improves clarity in the UI.

src/panels/config/automation/ha-automation-picker.ts (1)

268-268: Label modification approved.

The change from "state" to "icon" in the label is consistent with the PR objectives and enhances clarity. Ensure that the localization key ui.panel.config.automation.picker.headers.icon exists and is correctly set up in the localization files.

src/translations/en.json (3)

2737-2737: Approved addition of the "icon" key.

The addition of the "icon" key under the existing keys maintains the JSON structure's integrity and aligns with the project's localization updates.


3613-3613: Approved addition of the "icon" key.

This change is consistent with the project's efforts to enhance localization by adding more descriptive keys.


3733-3733: Approved addition of the "icon" key.

The addition of the "icon" key enhances the JSON structure and aligns with the project's localization strategy.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Outside diff range comments (10)
src/panels/lovelace/cards/hui-horizontal-stack-card.ts (1)

Line range hint 26-26: Static analysis issue: Use of super in static context.

Using super in a static method can lead to confusion. It's safer to reference the parent class directly by its name.

- super.sharedStyles,
+ HuiStackCard.sharedStyles,
src/panels/lovelace/cards/hui-card.ts (2)

Line range hint 103-103: Avoid using any type.

Using any disables TypeScript's type checking. Specify more precise types to enhance code safety and maintainability.

Also applies to: 163-163, 171-171, 172-172


Line range hint 114-114: Avoid non-null assertions.

Non-null assertions can lead to runtime errors. Use optional chaining (?.) or other checks instead.

- this._element!.hass = this.hass;
+ this._element?.hass = this.hass;

Also applies to: 298-298

src/panels/config/users/dialog-add-user.ts (1)

Line range hint 272-272: Avoid using any type.

Using any disables TypeScript's type checking. Specify more precise types to enhance code safety and maintainability.

Also applies to: 285-285

Tools
Biome

[error] 298-298: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

src/panels/config/script/ha-script-picker.ts (3)

Line range hint 220-220: Replace non-null assertions with optional chaining.

Non-null assertions have been used in various parts of the code, which can lead to runtime errors if not handled properly. Replacing these with optional chaining will make the code safer and more robust.

- this.hass!
+ this.hass?.  // Apply this change to all relevant lines

Also applies to: 240-240, 857-857, 868-868, 881-881, 904-904, 1162-1163


Line range hint 844-844: Reduce cognitive complexity in the function.

The function _handleBulkArea has a cognitive complexity of 28, which is above the recommended threshold. Consider refactoring to simplify this function, possibly by breaking it down into smaller, more manageable functions.


Line range hint 957-957: Specify more precise types instead of using any.

The use of any type at various places reduces the benefits of TypeScript's static type checking. It is advisable to replace any with more specific types to improve code reliability and maintainability.

- private _duplicate(script: any) {
+ private _duplicate(script: ScriptEntity) {

Also applies to: 1067-1067, 1082-1082, 1086-1086, 1093-1093, 1120-1120, 1135-1135, 1153-1153, 1169-1169, 1177-1177

src/panels/config/automation/ha-automation-picker.ts (3)

Line range hint 230-230: Replace non-null assertions with optional chaining.

Using non-null assertions can lead to runtime errors if the object is null or undefined. It's safer to use optional chaining.

- this._overflowMenu!.open
+ this._overflowMenu?.open

- this.hass!.localize("ui.common.delete")
+ this.hass?.localize("ui.common.delete")

- this.hass!.localize("ui.common.cancel")
+ this.hass?.localize("ui.common.cancel")

- this.hass!.localize("ui.panel.config.automation.picker.bulk_actions.enable")
+ this.hass?.localize("ui.panel.config.automation.picker.bulk_actions.enable")

- this.hass!.localize("ui.panel.config.automation.picker.bulk_actions.disable")
+ this.hass?.localize("ui.panel.config.automation.picker.bulk_actions.disable")

- this.hass!.localize("ui.panel.config.automation.picker.delete")
+ this.hass?.localize("ui.panel.config.automation.picker.delete")

- this.hass!.localize("ui.panel.config.automation.picker.delete_confirm_title")
+ this.hass?.localize("ui.panel.config.automation.picker.delete_confirm_title")

- this.hass!.localize("ui.panel.config.automation.picker.delete_confirm_text", { name: automation.name })
+ this.hass?.localize("ui.panel.config.automation.picker.delete_confirm_text", { name: automation.name })

Also applies to: 251-251, 964-964, 975-975, 989-989, 1012-1012, 1137-1137, 1138-1138


Line range hint 951-951: Refactor to reduce complexity in _applyFilters.

The complexity of _applyFilters exceeds the recommended limit, which can make the function difficult to understand and maintain. Consider breaking it down into smaller, more focused functions.


Line range hint 1147-1147: Avoid using any type for better type safety.

Using any type disables TypeScript's type checking, which can lead to less predictable code. Specify explicit types where possible.

Also applies to: 1171-1171

@@ -31,6 +31,8 @@ export class HuiCard extends ReactiveElement {

@property({ attribute: false }) public hass?: HomeAssistant;

private _elementConfig?: LovelaceCardConfig;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New properties and methods look good, but consider type safety improvements.

The introduction of _elementConfig and methods like _updateElement enhance modularity and maintainability. However, consider replacing any types with more specific ones.

- catch (e: any) {
+ catch (e: Error) {

Also applies to: 86-93, 97-97, 147-154

{
type: "homeassistant",
},
];
this._params!.userAddedCallback(user);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid non-null assertions.

Non-null assertions can lead to runtime errors. Use optional chaining (?.) or other checks instead.

- this._params!.userAddedCallback(user);
+ this._params?.userAddedCallback(user);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this._params!.userAddedCallback(user);
this._params?.userAddedCallback(user);
Tools
Biome

[error] 298-298: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants